/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package czStvDpds.bullets;

import czStvDpds.graphics3D.GraphicalBullet;
import czStvDpds.graphics3D.geometry.Object3D;

/**
 *
 * @author Vašek
 */
public class Bullet implements AbstractBullet, GraphicalBullet {

    double x, y, yaw, speed;
    int id = -1; //id toho, který vystřelil

    public Bullet(double x, double y, double yaw, double speed, int id) {
        this.x = x;
        this.y = y;
        this.yaw = yaw;
        this.speed = speed;
        this.id = id;
    }

    @Override
    public double getX() {
        return x;
    }

    @Override
    public double getY() {
        return y;
    }

    @Override
    public double getYaw() {
        return yaw;
    }

    @Override
    public double getSpeed() {
        return speed;
    }

    public boolean step(int time) { //vrátí false pokud by se měla střela zničit - dočasné řešení
        x += Math.cos(Math.toRadians(yaw)) * speed * time;
        y += Math.sin(Math.toRadians(yaw)) * (-speed) * time;
        return true;
    }
    ////////////////////////garfická část/////////////////////////////
    private Object3D mesh;

    @Override
    public double getGraphicsX() {
        return this.x;
    }

    @Override
    public double getGraphicsY() {
        return this.y;
    }

    @Override
    public double getGraphicsYaw() {
        return this.yaw;
    }

    @Override
    public double getGraphicsZ() {
        return 0.65;
    }

    @Override
    public Object3D getObject3D() {
        return this.mesh;
    }

    @Override
    public void setObject3D(Object3D mesh) {
        this.mesh = mesh;
    }
}
